package 创建型模式

import java.nio.file.Path

/**
 * 提供一个创建一系列相关或相互依赖对象的接口，而无需指定它们具体的类。
 */

/**
 * 是工厂的抽象，封装的是一套接口
 * 具体实现交由其他的工厂
 */
interface AbstractFactory {
    fun createHtml(md: String): HtmlDocument
    fun createWord(md: String): WordDocument

    companion object {
        fun createFactory(name: String): AbstractFactory {
            return if (name == "fast") {
                FastFactory()
            } else {
                GoodFactory()
            }
        }
    }
}


interface HtmlDocument {
    fun toHtml()
    fun save(path: Path)
}

interface WordDocument {
    fun save(path: Path)
}


class FastHtmlDocument(md: String) : HtmlDocument {
    override fun toHtml() {
    }

    override fun save(path: Path) {
    }

}

class FastWordDocument(md: String) : WordDocument {
    override fun save(path: Path) {
    }
}

class FastFactory : AbstractFactory {
    override fun createHtml(md: String): HtmlDocument {
        return FastHtmlDocument(md)
    }

    override fun createWord(md: String): WordDocument {
        return FastWordDocument(md)
    }

}

class GoodHtmlDocument(md: String) : HtmlDocument {
    override fun toHtml() {
    }

    override fun save(path: Path) {
    }

}

class GoodWordDocument(md: String) : WordDocument {
    override fun save(path: Path) {
    }

}

class GoodFactory : AbstractFactory {
    override fun createHtml(md: String): HtmlDocument {
        return GoodHtmlDocument(md)
    }

    override fun createWord(md: String): WordDocument {
        return GoodWordDocument(md)
    }

}


fun main() {

}